import cookies from "vue-cookies";
export default {
  state: {
    token: "",
    userInfo: "",
    uniacid: 2
  },
  mutations: {
    // 登录成功 vuex 和 cookies 中保存数据
    setInfo(state, val) {
      state.token = val.token;
      state.userInfo = val.userInfo;
      state.uniacid = val.uniacid;
    },
    // 退出登录的时候清除
    clearToken(state) {
      state.token = "";
      state.userInfo = "";
      state.uniacid = "";
      cookies.remove("token");
      cookies.remove("userInfo");
      cookies.remove("uniacid");
    },
    // 刷新的时候保存数据
    getInfo(state) {
      state.token = cookies.get("token");
      state.userInfo = cookies.get("userInfo");
      state.uniacid = cookies.get("uniacid");
    }
  },
  actions: {}
};
